package com.zsrt.java.day20161230.wrl.demo02;

public class Sturdent {
	private String name;
	private char sex;
	private String identity;
	private int age;
	private String school;
	
	@Override
	public String toString() {
		return "Sturdent [name= " + name + " , sex= " + sex + " , identity= " + identity + " , age= " + age + " , school= " + school + "]";
	}
	
	public String getName() {
		return name;
	}
	
	/**
	 * 一个类如果没有调用它的构造方法  null
	 * @param name
	 */
	public void setName(String name) {
		if(name != null){
			int len = name.length();
			if(len>=2&&len<=4){
				this.name = name;
			}
		}
	}
	public String getIdentity() {
		return identity;
	}
	public void setIdentity(String identity) {
		if(identity.length()==18){
			this.identity = identity;
		}
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		if(age>=1&&age<=120){
			this.age = age;
		}
	}
	public String getSchool() {
		return school;
	}
	public void setSchool(String school) {
		this.school = school;
	}

	public char getSex() {
		return sex;
	}

	public void setSex(char sex) {
		if(sex=='女'||sex=='男'){
			this.sex = sex;
		}else{
			this.sex = '略';
		}
	}

}
